/*
 * CANLoopback.c
 *
 *  Created on: 2017-2-23
 *      Author: Mahome
 */
#include "BSW_Include.h"
#define CAN0RxIDNum 22
#define CAN1RxIDNum 0
ulong CAN0RxID[CAN0RxIDNum] =
{
		0x18010027,
		0x1C01D0D2,
		0x1C02D0D2,
		0x1C03D0D2,
		0x1C04D0D2,
		0x1C05D0D2,
		0x1C06D0D2,
		0x18FFDD17,
		0x18FEDD17,
		0x1423D0D2,
		0x18FF2DF3,
		0x0C0117A7,
		0x0CFFEDEF,
		0x0CFFEBEF,
		0x18FFECEF,
		0x1813D0D2,
		0x1814D0D2,
		0x0C1FD0D2,
		0x1825D0D2,
		0x1C15D0D2,
		0x1C64D0D2
};

ulong CAN1RxID[CAN1RxIDNum] =
{

};

static ubyte CNT = 0;
void CANLoopTestAPI(void)
{
	static ubyte CAN0Sendidx = 0;
	static ubyte CAN1Sendidx = 0;

	CNT=1;
	CANRxMOStr Tx;
	if(CAN0RxIDNum>0)
	{
		Tx.Identifier = CAN0RxID[CAN1Sendidx++];
		Tx.DataLength = 8;
		Tx.IDExten = 1;
		Tx.data[0] = CAN1Sendidx+0x40;
		Tx.data[1] = CNT;
		for(ubyte i=2;i<8;i++)
			Tx.data[i]=0;
	//	SEGGER_RTT_printf(0, "The CAN1Sendidx is 0x%08X!\r\n",Tx.Identifier);
		CAN_Send(1,Tx);
		if (CAN1Sendidx >=CAN0RxIDNum) 	CAN1Sendidx = 0;
	}
	if(CAN1RxIDNum>0)
	{
		Tx.Identifier = CAN1RxID[CAN0Sendidx++];
		Tx.DataLength = 8;
		Tx.IDExten = 1;
		Tx.data[0] = CAN0Sendidx+0x80;
		Tx.data[1] = CNT;
		for(ubyte i=2;i<8;i++)
			Tx.data[i]=0;
	//	SEGGER_RTT_printf(0, "The CAN0Sendidx is 0x%02X!\r\n",Tx.Identifier);
		CAN_Send(0,Tx);
		if (CAN0Sendidx >=CAN1RxIDNum) 	CAN0Sendidx = 0;
	}



}


